package com.kukudb.captcharepeater.controller;

import com.kukudb.captcharepeater.pojo.ResponseMessage;
import com.kukudb.captcharepeater.pojo.Users;
import com.kukudb.captcharepeater.serveice.UserServerImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api")    // localhost:81/api/user
@Slf4j
public class UserControllerApi {

    @Autowired
    UserServerImpl useServer;

    @PostMapping("/getCode")
    public ResponseMessage<String> getCode(@RequestBody Users user) {
        log.info("phone:{}",user.getPhone());
        //获取推广员，对推广员内进行登记

        ResponseMessage<String>  responseMessage = useServer.getCode(user);
        return responseMessage;
    }

    @PostMapping("/submitCode")
    public ResponseMessage<String> submitCode(@RequestBody Users user) {
        log.info("phone:{}",user);
       return useServer.submitCode(user);
    }

    @PostMapping("/isOK")
    public ResponseMessage<String> isOK(@RequestBody Users user) {
        log.info("phone:{}",user.getPhone());
        return useServer.isOK(user.getPhone());
    }
}

